package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;

import DataObjects.RecipeLeftList;

public class GetAllItemsForNewRecipe {
	
	public GetAllItemsForNewRecipe()
	{
		
	}
	
	public Vector<RecipeLeftList> getItems()
	{
		Vector<RecipeLeftList> items=new Vector<RecipeLeftList>();
		
     SQLConnection sc=new SQLConnection();
		
		
		try {
			
		PreparedStatement ps = sc.getConnection().prepareStatement("SELECT it.Iid ,it.Iname,ICategory,IExpiration,IMin_quantity,IMax_quantity,IUnit_of_measure,Icost FROM item it ;");	
        
		ResultSet rs=ps.executeQuery();	

		
		
		 while(rs.next())
	        {   

			 RecipeLeftList  row = new RecipeLeftList();
	                               	                	               
	                 row.setItemID(rs.getInt(1));
	                 row.setItemName(rs.getString(2));
	                 row.setiCategory(rs.getString(3));
	                 row.setiExpiration(rs.getString(4));
	                 row.setiMin(rs.getFloat(5));
	                 row.setiMax(rs.getFloat(6));
	                 row.setIUnit_of_measure(rs.getString(7));
	                 row.setiCost(rs.getFloat(8));
	         	//for
	         items.add(row);
	        }//while
		 ps.close();
		 rs.close();
		 sc.getConnection().close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return items;
	}

}
